import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(title: Text('Flutter Demo')),
            //body内容多抽离出去
            body: HomeContent()));
  }
}

//body
class HomeContent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return LayoutDemo();
  }
}

//layoutdemo
class LayoutDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        height: 600.0,
        width: 600.0,
        color: Colors.pink,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly, //均匀分配
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            IconContainer(Icons.home, color: Colors.black),
            IconContainer(Icons.search, color: Colors.orange),
            IconContainer(Icons.select_all, color: Colors.blue),
            IconContainer(Icons.send, color: Colors.yellow)
          ],
    ));
  }
}

class IconContainer extends StatelessWidget {
  double size = 32.0;
  Color color = Colors.red;
  IconData icon;

  IconContainer(this.icon, {this.color, this.size});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100,
      width: 100,
      color: this.color,
      child: Center(
        child: Icon(this.icon, size: this.size, color: Colors.white),
      ),
    );
  }
}
